package com.thinkingcoder.tccache.core.command.zset;

import static com.thinkingcoder.tccache.constant.CommandConstants.ZSetCmd.ZRANK;

import com.thinkingcoder.tccache.core.TcCache;
import com.thinkingcoder.tccache.core.command.Command;
import com.thinkingcoder.tccache.core.model.Reply;

/**
 * ZRANK command.
 */
public class ZRankCmd implements Command {
    @Override
    public String name() {
        return ZRANK;
    }

    @Override
    public Reply<?> exec(TcCache cache, String[] args) {
        String key = getKey(args);
        String val = getValue(args);
        return Reply.integer(cache.zRank(key, val));
    }
}
